//#########################################################################
//                              WackiEngie
//           Copyright (c) 2014 Marc Wacker. All rights reserved.
//#########################################################################

#pragma once

#include "WeUtilPrerequisites.h"

#include "WeVector3.h"
#include "WeMatrix3.h"


namespace WackiEngine
{

	template<class T>
	class Quaternion
	{
	public:
		T	x, y, z, w;

		Quaternion(T x_ = 0, T y_ = 0, T z_ = 0, T w_ = 1);
		Quaternion(const Matrix3<T>& m);
		Quaternion(T angle, const Vector3<T>& axis);

		void			set(const Matrix3<T> &m);
		void			set(T angle, const Vector3<T>& axis);

		void			normalize();

		Quaternion<T>	lerp(const Quaternion<T>& q2, const T t) const;

		void			lerp(const Quaternion<T>& q1, const Quaternion<T>& q2, const T t);

		Quaternion<T>	slerp(const Quaternion<T>& q2, const T t) const;

		void			slerp(const Quaternion<T>& q1, const Quaternion<T>& q2, const T t);

		// best interpolation, slerp or lerp what ever fits best
		static void interpolate(Quaternion<T>& out, const Quaternion<T>& start, const Quaternion<T>& end, const T factor);

		Matrix3<T>	getMatrix() const;
	};

}